package com.itqhy.service;

import com.itqhy.dao.OrderMapper;
import com.itqhy.pojo.Order;
import com.itqhy.pojo.OrderItem;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Transactional
@Service("orderService")
public class OrderServiceImpl implements OrderService{
    @Resource(name = "orderMapper")
    private OrderMapper orderMapper;

    public void saveOrder(Order order) {
        orderMapper.saveOrder(order);

    }

    public void saveOrderIdAndProductId(OrderItem orderItem) {

        orderMapper.saveOrderIdAndProductId(orderItem);

    }


    public int countOrderByUserId(int user_id) {
        return orderMapper.countOrderByUserId(user_id);
    }


    public List<Order> findOrderByUserId(int user_id) {
        return orderMapper.findOrderByUserId(user_id);

    }


    public Order findProductByOrderId(String order_id) {

        System.out.println("service中得到的order_id为"+order_id);

        return orderMapper.findProductByOrderId(order_id);


    }


    public void deleteOrderById(String order_id) {
        orderMapper.deleteOrderById(order_id);

    }


    public void deleteOrderItemById(String order_id) {
        orderMapper.deleteOrderItemById(order_id);

    }

}
